package com.googlecode.grs.environment;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;

import com.googlecode.grs.ui.Drawable;

/**
 * Serves as a barrier in simulated mazes
 * 
 * @author anand
 * 
 */
public class Wall extends PhysicalObject implements Drawable {

	private static final Color BORDER = Color.black;
	private static final Color FILL = Color.gray;

	private double width;
	private double height;

	/**
	 * Constructs a wall with rectangle synatax
	 * 
	 * @param x
	 *            the X coordinate of the upper-left corner of the wall
	 * @param y
	 *            the Y coordinate of the upper-left corner of the
	 * @param width
	 *            the width of the wall TODO define as vertical/horizontal
	 * @param height
	 *            the height of the wall TODO define vertical/horizontal
	 */
	public Wall(double x, double y, double width, double height) {
		super(x, y);
		this.width = width;
		this.height = height;
	}

	/**
	 * Checks if a provided point is in this wall
	 * 
	 * @param x
	 *            x coordinate of point
	 * @param y
	 *            y coordinate of point
	 * @return true if point is intersecting(inside) wall
	 */
	public boolean intersects(double x, double y) {
		return (new Rectangle2D.Double(this.x, this.y, width, height).contains(
				x, y));
	}

	/**
	 * @see SimulationEnvironment.draw()
	 */
	public void draw(Graphics g) {
		g.setColor(BORDER);
		g.drawRect((int) x, (int) y, (int) width, (int) height);
		g.setColor(FILL);
		g.fillRect((int) x, (int) y, (int) width, (int) height);
	}

	/**
	 * 
	 * @return width of this wall
	 */
	public double getWidth() {
		return width;
	}

	/**
	 * 
	 * @return height of this wall
	 */
	public double getHeight() {
		return height;
	}

	// TODO neccessary?
	/**
	 * Sets the width of this wall
	 * 
	 * @param width
	 *            new width
	 */
	public void setWidth(double width) {
		this.width = width;
	}

	// TODO neccessary?
	/**
	 * Sets the height of this wall
	 * 
	 * @param height
	 *            new height
	 */
	public void setHeight(double height) {
		this.height = height;
	}
}
